<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('信息安全测评报告列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>时间： </label>
                            <input type="text" class="time-input" id="beginTime" data-format="yyyy-MM-dd HH:mm:ss"
                                   placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" data-format="yyyy-MM-dd HH:mm:ss"
                                   placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>

                        <li>
                            <label>内容：</label>
                            <input type="text" id="description" name="description"/>
                        </li>

                        <li>
                            <label>版本：</label>
                            <input type="text" id="version" name="version"/>
                        </li>
                        <li>
                            <label>类型：</label>
                            <input type="text" id="type" name="type"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select id="suffix" name="suffix">
                                <option value="">所有</option>
                                <option value="Incomplete">Incomplete</option>
                                <option value="Pass">Pass</option>
                                <option value="Fail">Fail</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search();loadSta()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 search-collapse">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>汇总信息</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-12">
                            <table class="table table-hover margin bottom">
                                <tbody>
                                <tr>
                                    <td>测试用例</td>
                                    <td id="total">0</td>

                                </tr>
                                <tr>
                                    <td> 测试用例成功</td>
                                    <td id="totalEx">0</td>

                                </tr>
                                <tr>
                                    <td>测试用例失败</td>
                                    <td id="totalFa">0</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="biz:info:add">-->
                <!--<i class="fa fa-plus"></i> 测试添加数据-->
            <!--</a>-->
            <a class="btn btn-warning" onclick="exportExcel2()" shiro:hasPermission="biz:info:export">
                <i class="fa fa-download"></i> 查询条件导出
            </a>
            <a class="btn btn-danger multiple disabled" onclick="exportExcelRows()"
               shiro:hasPermission="biz:info:export">
                <i class="fa fa-download"></i> 选择文件导出
            </a>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>

</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('biz:info:edit')}]];
    var removeFlag = [[${@permission.hasPermi('biz:info:remove')}]];
    var prefix = ctx + "biz/info";

    $(function () {
        var options = {
            url: prefix + "/list?rootFlag=0",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/detail/{id}",
            exportUrl: prefix + "/export2",
            modalName: "详细",
            uniqueId: 'childId',
            columns: [{
                checkbox: true
            },
                {
                    field: 'prefix',
                    title: '时间',
                    sortable: true
                },
                {
                    field: 'suffix',
                    title: '状态',
                    sortable: true
                },
                {
                    field: 'description',
                    title: '内容',
                    sortable: true
                },
                {
                    field: 'version',
                    title: '版本',
                    sortable: true
                },

                {
                    field: 'type',
                    title: '类型',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detailInfo(\'' + row.id + '\')"><i class="fa fa-edit"></i>详细</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
        loadSta();
    });

    /**
     * 详细信息
     */
    function detailInfo(id) {
        var options = {
            title: '详细信息',
            width: "1200",
            height: "550",
            url: prefix + "/detail/" + id,
            btn: ['关闭'],
            yes: function (index, layero) {
                layer.close(index);
            }
        };
        $.modal.openOptions(options);


    }

    /**
     * 根据查询条件导出excel
     */
    function exportExcel2() {
        window.open(prefix + "/export?description=" + $("#description").val() + "&version=" + $("#version").val() + "&type=" + $("#type").val() + "&suffix=" + $("#suffix").val() + "&beginTime=" + $("#beginTime").val() + "&endTime=" + $("#endTime").val())
    }

    /**
     * 选中行导出excel
     */
    function exportExcelRows() {
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length === 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要导出选中的" + rows.length + "条数据吗?", function () {
            var idsStr = rows.join(',');
            window.open(prefix + "/exportRows?ids=" + idsStr)
        });
    }

    /**
     * 获取汇总个数
     */
    function loadSta() {
        $.get(prefix + "/getTotal?description=" + $("#description").val() + "&version=" + $("#version").val() + "&type=" + $("#type").val() + "&suffix=" + $("#suffix").val() + "&beginTime=" + $("#beginTime").val() + "&endTime=" + $("#endTime").val(), function (data) {
            $("#total").text(data.total);
            $("#totalEx").text(data.executeTotal);
            $("#totalFa").text(data.failTotal);
        })
    }


    $(".modal").appendTo("body"), $("[data-toggle=popover]").popover(), $(".collapse-link").click(function () {
        var div_ibox = $(this).closest("div.ibox"),
            e = $(this).find("i"),
            i = div_ibox.find("div.ibox-content");
        i.slideToggle(200),
            e.toggleClass("fa-chevron-up").toggleClass("fa-chevron-down"),
            div_ibox.toggleClass("").toggleClass("border-bottom"),
            setTimeout(function () {
                div_ibox.resize();
            }, 50);
    }), $(".close-link").click(function () {
        var div_ibox = $(this).closest("div.ibox");
        div_ibox.remove()
    });

</script>
</body>
</html>